<template>
  <div class="fullscreen-container">
    <div class="content-wrapper">
      <el-card style="width: 100%;">
      <template #header>
        <div class="card-header">
          <span>成绩查询</span>
        </div>
      </template>
      <div class="search-bar">
        <el-input v-model="searchQuery" placeholder="请输入考试名称" prefix-icon="Search" style="width: 400px;" />
        <el-select v-model="courseFilter" placeholder="选择课程" style="width: 200px; margin-left: 10px;">
          <el-option label="全部课程" value=""></el-option>
          <el-option label="高等数学" value="1"></el-option>
          <el-option label="线性代数" value="2"></el-option>
          <el-option label="概率论" value="3"></el-option>
        </el-select>
        <el-button type="primary" @click="handleSearch">搜索</el-button>
      </div>
      <el-table :data="scoresData" style="width: 100%">
        <el-table-column prop="scoreId" label="成绩ID" width="80"></el-table-column>
        <el-table-column prop="examName" label="考试名称"></el-table-column>
        <el-table-column prop="courseName" label="所属课程" width="120"></el-table-column>
        <el-table-column prop="score" label="得分" width="80">
          <template #default="{ row }">
            <span :class="['score-value', { 'score-high': row.score >= 80, 'score-medium': row.score >= 60 && row.score < 80, 'score-low': row.score < 60 }]">
              {{ row.score }}
            </span>
          </template>
        </el-table-column>
        <el-table-column prop="totalScore" label="总分" width="80"></el-table-column>
        <el-table-column prop="rank" label="排名" width="80">
          <template #default="{ row }">
            <el-tag size="small" type="success">第{{ row.rank }}名</el-tag>
          </template>
        </el-table-column>
        <el-table-column prop="examTime" label="考试时间" width="180"></el-table-column>
        <el-table-column prop="status" label="状态" width="100">
          <template #default="{ row }">
            <el-tag v-if="row.status === '已批改'" type="info">已批改</el-tag>
            <el-tag v-else type="warning">待批改</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="操作" width="100">
          <template #default="{ row }">
            <el-button size="small" @click="handleView(row)">查看详情</el-button>
          </template>
        </el-table-column>
      </el-table>
      <div class="pagination">
        <el-pagination
          v-model:current-page="currentPage"
          v-model:page-size="pageSize"
          :page-sizes="[10, 20, 50, 100]"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
        />
      </div>
      </el-card>
    </div>
  </div>
</template>

<script setup lang="ts">
import { ref, reactive } from 'vue'
import { ElMessage } from 'element-plus'
import { Search } from '@element-plus/icons-vue'

// 模拟成绩数据
const scoresData = ref([
  { scoreId: 1, examName: '高等数学期中考试', courseName: '高等数学', score: 85, totalScore: 100, rank: 5, examTime: '2024-10-15 09:00:00', status: '已批改' },
  { scoreId: 2, examName: '线性代数单元测试', courseName: '线性代数', score: 78, totalScore: 100, rank: 12, examTime: '2024-10-10 14:00:00', status: '已批改' },
  { scoreId: 3, examName: '概率论基础测验', courseName: '概率论', score: 62, totalScore: 100, rank: 20, examTime: '2024-10-05 10:00:00', status: '待批改' }
])

const searchQuery = ref('')
const courseFilter = ref('')
const currentPage = ref(1)
const pageSize = ref(10)
const total = ref(scoresData.value.length)

const handleView = (row: any) => {
  // 查看详情功能
  ElMessage.info(`查看成绩详情：${row.examName} - ${row.score}/${row.totalScore}`)
}

const handleSearch = () => {
  // 搜索功能
  ElMessage.info(`搜索：${searchQuery.value}，课程：${courseFilter.value}`)
}

const handleSizeChange = (size: number) => {
  pageSize.value = size
}

const handleCurrentChange = (current: number) => {
  currentPage.value = current
}
</script>

<style scoped>
.fullscreen-container {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100vw;
  height: 100vh;
  background-color: #f5f5f5;
  padding: 0;
  margin: 0;
  box-sizing: border-box;
  position: fixed;
  left: 0;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 1;
  overflow: hidden;
}

.content-wrapper {
  width: 100%;
  height: 100%;
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

.card-header {
  font-size: 18px;
  font-weight: bold;
}

.search-bar {
  margin-bottom: 20px;
  display: flex;
  gap: 10px;
  align-items: center;
}

.score-value {
  font-weight: bold;
}

.score-high {
  color: #67c23a;
}

.score-medium {
  color: #e6a23c;
}

.score-low {
  color: #f56c6c;
}

.pagination {
  margin-top: 20px;
  display: flex;
  justify-content: flex-end;
}
</style>